﻿using System;

namespace TemplateMethodPattern;

//模板方法模式
public abstract class Cooking
{
    protected abstract void Step1();
    protected abstract void Step2();

    public void Cook()
    {
        Step1();
        Step2();
    }
}

public class CookingFood : Cooking
{
    protected override void Step1()
    {
        Console.WriteLine("放西红柿和鸡蛋");
    }

    protected override void Step2()
    {
        Console.WriteLine("放少许盐和味精");
    }
}

public static class Program
{
    public static void Main()
    {
        Cooking cookTest = new CookingFood();
        cookTest.Cook();
    }
}